package com.metamech.wocky;

import com.metamech.jabber.xml.Packet;
import com.metamech.jabber.xml.PacketListener;
import com.metamech.log.Log;

public class IQHandler implements PacketListener {

	JabberModel jabberModel;
  
	public IQHandler(JabberModel model){
		jabberModel = model;
	}  

	public void notify(Packet packet) {
		if (packet.getID() != null){
			PacketListener listener = jabberModel.removeResultHandler(packet.getID());
			if (listener != null){
				if(listener instanceof RegisterHandler){
					Log.trace("Notify Register Handler");
				}
				listener.notify(packet);
				return;
			}
		}
		Log.trace("Dropping : " + packet.toString());
	}
}